RewriteEngine On
RewriteCond %{HTTPS} !=on

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

IndexIgnore *
ErrorDocument 404 /index.php

# Redirect /admin/ to /admin/index.php if it exists
RewriteCond %{REQUEST_URI} ^/AADA/?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/AADA/index\.php -f
RewriteRule ^AADA/?$ /AADA/index.php [L]

# Redirect /pay/ to /pay/index.html if it exists
RewriteCond %{REQUEST_URI} ^/pay/?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/pay/index\.html -f
RewriteRule ^pay/?$ /pay/index.html [L]

#take off index.html
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule . https://%{HTTP_HOST}%1 [R=301,NE,L]

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit